package com.example.lyl.andfixdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.lyl.andfixdemo.andfix.AndFixPatchManager;
import com.example.lyl.andfixdemo.util.Utils;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    private static final String FILE_END = ".apatch";
    private String mPatchDir;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mPatchDir = getExternalCacheDir().getAbsolutePath() + "/apatch/";

        File file = new File(mPatchDir);

        //创建文件夹
        if (file == null || !file.exists()) {
            file.mkdir();
        }
    }

    public void createBug(View view) {
        Utils.printLog();
    }

    public void fixBug(View view) {
        AndFixPatchManager.getInstance().addPatch(getPatchName());
    }

    //构造Patch文件名
    private String getPatchName() {
        return mPatchDir.concat("lyl").concat(FILE_END);
    }
}
